home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Freeware / Griffith 0.9.8 / griffith-0.9.8-win32.exe / {app} / lib / plugins / movie / PluginMovieTanukiAnime.py < prev    next >
Text File  |  2008-11-17  |  6KB  |  165 lines

  1. # -*- coding: utf-8 -*-
  2.  
  3. __revision__ = '$Id: PluginMovieTanukiAnime.py 1040 2008-11-15 21:13:49Z mikej06 $'
  4.  
  5. # Copyright (c) 2005-2007 Piotr O┼╝arowski
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. # GNU Library General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  20.  
  21. # You may use and distribute this software under the terms of the
  22. # GNU General Public License, version 2 or later
  23.  
  24. import gutils
  25. import movie,string
  26.  
  27. plugin_name         = 'Tanuki-Anime'
  28. plugin_description  = 'Najwi─Ökszy zbi├│r recenzji anime w Polsce'
  29. plugin_url          = 'anime.tanuki.pl'
  30. plugin_language     = _('Polish')
  31. plugin_author       = 'Piotr Ozarowski'
  32. plugin_author_email = '<ozarow+griffith@gmail.com>'
  33. plugin_version      = '1.3'
  34.  
  35. class Plugin(movie.Movie):
  36.     def __init__(self, id):
  37.         if str(id).find('http://') != -1:
  38.             self.movie_id = 'TA'
  39.             self.url = str(id)
  40.         else:
  41.             self.movie_id = str(id)
  42.             self.url = "http://anime.tanuki.pl/strony/anime/%s" % str(id)
  43.         self.encode='UTF-8'
  44.     
  45.     def initialize(self):
  46.         if self.movie_id == 'TA':
  47.             self.movie_id = gutils.trim(self.page, '"><a href="/strony/anime/', '/oceny')
  48.             self.url = "http://anime.tanuki.pl/strony/anime/%s" % self.movie_id
  49.  
  50.     def get_image(self):
  51.         self.image_url = gutils.trim(self.page, '<img src="/screens/', '<br />')
  52.         self.image_url = gutils.before(self.image_url, '"')
  53.         self.image_url = "http://anime.tanuki.pl/screens/%s" % self.image_url
  54.  
  55.     def get_o_title(self):
  56.         self.o_title = gutils.trim(self.page, '<h3 class="animename"', '</h3>')
  57.         self.o_title = gutils.after(self.o_title, '>')
  58.  
  59.     def get_title(self):
  60.         self.title = self.o_title
  61.  
  62.     def get_director(self):
  63.         self.director = gutils.trim(self.page, "<th scope=\"row\">Re┼╝yser:</th>\n\t<td>", '</td>')
  64.  
  65.     def get_plot(self):
  66.         self.plot = gutils.trim(self.page, "<div class=\"copycat\">\n", '</div>')
  67.  
  68.     def get_year(self):
  69.         self.year = gutils.trim(self.page,'<div class=\"sitem\">Rok wydania: <', '</a>')
  70.         self.year = gutils.after(self.year, '>')
  71.  
  72.     def get_runtime(self):
  73.         self.runtime = gutils.trim(self.page, "<div class=\"sitem\">Czas trwania: <b>\n\t\t", '\n</b>')
  74.         if self.runtime.find('?') != -1:
  75.             self.runtime = ''
  76.         else:
  77.             self.runtime = gutils.after(self.runtime, '├ù')
  78.             self.runtime = gutils.before(self.runtime, ' min')
  79.  
  80.     def get_genre(self):
  81.         self.genre = gutils.trim(self.page, "<div class=\"sitem\">Gatunki:\n\t\t", '</div>')
  82.         self.genre = string.replace(self.genre, "\t\t", ' ')
  83.  
  84.     def get_cast(self):
  85.         self.cast = ''
  86.  
  87.     def get_classification(self):
  88.         self.classification = ''
  89.  
  90.     def get_studio(self):
  91.         self.studio = gutils.trim(self.page, "<th scope=\"row\">Studio:</th>\n\t<td>\n", "\t</td>")
  92.  
  93.     def get_o_site(self):
  94.         self.o_site = ''
  95.  
  96.     def get_site(self):
  97.         self.site = self.url
  98.  
  99.     def get_trailer(self):
  100.         self.trailer = ''
  101.  
  102.     def get_country(self):
  103.         self.country = ''
  104.  
  105.     def get_rating(self):
  106.         self.rating = gutils.trim(self.page, ' alt="Ocena ', '/10')
  107.  
  108.     def get_notes(self):
  109.         self.notes = "Czas trwania: " + gutils.trim(self.page,"<div class=\"sitem\">Czas trwania: <b>\n\t\t","\n</b>") + '\n'
  110.  
  111.         t = self.page.find("<tr><th scope=\"row\">Autor:</th>")
  112.         if t != -1:
  113.             self.notes += "Autor: %s\n" % gutils.trim(self.page[t:], "<td>\n", "\t</td>")
  114.  
  115.         t = self.page.find("<th scope=\"row\">Projekt:</th>")
  116.         if t != -1:
  117.             self.notes += "Projekt: %s\n" % gutils.trim(self.page[t:], "<td>\n", "\t</td>")
  118.  
  119.         t = self.page.find("<tr><th scope=\"row\">Scenariusz:</th>")
  120.         if t != -1:
  121.             self.notes += "Scenariusz: %s\n" % gutils.trim(self.page[t:], "<td>\n", "\t</td>")
  122.  
  123.         t = self.page.find("<th scope=\"row\">Muzyka:</th>")
  124.         if t != -1:
  125.             self.notes += "Muzyka: %s\n" % gutils.trim(self.page[t:], "<td>\n", "\t</td>")
  126.  
  127.         self.notes += "\n%s"  % gutils.trim(self.page,"<p class=\"dwazdania\">\n\t\t", "\n</p>")
  128.  
  129. class SearchPlugin(movie.SearchMovie):
  130.     def __init__(self):
  131.         self.encode='UTF-8'
  132.         self.original_url_search   = 'http://anime.tanuki.pl/strony/anime/lista/title/1/?&title='
  133.         self.translated_url_search = 'http://anime.tanuki.pl/strony/anime/lista/title/1/?&title='
  134.  
  135.     def search(self,parent_window):
  136.         self.open_search(parent_window)
  137.         tmp = string.find(self.page, "<table class=\"animelist strippedlist\"")
  138.         if tmp == -1:    # only one match!
  139.             self.page = ''
  140.         else:        # multiple matches
  141.             self.page = gutils.trim(self.page,"<table class=\"animelist strippedlist\"", "</tbody>");
  142.             self.page = gutils.after(self.page, "<tbody>")
  143.         return self.page
  144.  
  145.     def get_searches(self):
  146.         if self.page == '':    # immediately redirection to movie page
  147.             self.number_results = 1
  148.             self.ids.append(self.url)
  149.             self.titles.append(gutils.convert_entities(self.title))
  150.         else:            # multiple matches
  151.             elements = string.split(self.page,"<tr")
  152.             self.number_results = elements[-1]
  153.             if (elements[0]<>''):
  154.                 for element in elements:
  155.                     self.ids.append(gutils.trim(element, 'href="/strony/anime/', '" >'))
  156.                     element = gutils.after(element," >\n\t")
  157.                     element = element.replace("</a>\n\t</td>\n", " (")
  158.                     element = element.replace("\t<td>", "")
  159.                     element = element.replace("</td>\n", "; ")
  160.                     element = element.replace("</tr>", "")
  161.                     element = element[:len(element)-3] + ')'
  162.                     self.titles.append(element)
  163.             else:
  164.                 self.number_results = 0
  165.